<template>
  <div style="height: 100%;overflow:hidden">
    <x-header :left-options="{preventGoBack:true,backText: ''}" @on-click-back="backhome">日常巡检单填写</x-header>
    <div class="main-container" style="height:93%">
      <!-- <div id="map"></div> -->
      <v-touch v-on:swiperight="onSwipeRight" :swipe-options="{direction: 'horizontal'}">
        <div>
          <group>
            <!-- <cell title="项目（部）"
                  v-model="pro"
                  is-link
                  link="proListc1">
            </cell>-->
            <select-project
              title="项目（部）"
              formType="rectify"
              module="danger"
              status="add"
              :showValue="true"
              v-model="pro"
              @selectPro="selectPro"
            ></select-project>
            <x-input title="任务名称" v-model="subject" text-align="right"></x-input>
            <calendar v-model="startDate" title="要求整改日期" disable-past></calendar>
          </group>
          <group title="检查情况">
            <x-textarea placeholder="请输入一段描述" v-model="DESCRIPTION" :max="500"></x-textarea>
          </group>
          <group title="问题图片">
            <picture-upload :pageToken="pageToken" v-model="fieldToken"></picture-upload>
          </group>
          <group>
            <x-switch
              title="短信通知"
              v-model="notifyMethod"
              :value-map="['0,0,0','0,1,0']"
              @on-change="loga"
            ></x-switch>
          </group>
          <group>
            <cell title="签发人" v-model="name"></cell>
            <cell title="联系电话" v-model="phone"></cell>
            <cell title="填写部门" v-model="dept"></cell>
            <cell title="填写时间" v-model="inputDate"></cell>
          </group>

          <group>
            <person-tree
              title="检查人"
              v-model="checkPerson"
              :personid="checkPersonId"
              @selectUser="selectCheckPerson"
              :defaultValue="checkPersonId"
            ></person-tree>
            <person-tree
              title="检查组员"
              :multiple="true"
              v-model="inspectMemberFullName"
              :personid="inspectMemberName"
              :defaultValue="inspectMemberName"
              @selectUser="selectInspectMember"
              style="border-top: 1px solid #f5f5f5;"
            ></person-tree>
          </group>
          <group>
            <person-tree
              title="整改负责人"
              :multiple="true"
              v-model="person"
              :personid="personId"
              :defaultValue="personId"
              @selectUser="selectPerson"
            ></person-tree>
          </group>
          <group>
            <person-tree
              title="监理负责人"
              :multiple="true"
              v-model="SUPERVISORFULLNAME"
              :personid="SUPERVISORNAME"
              :defaultValue="SUPERVISORNAME"
              @selectUser="selectSupervisorFullName"
            ></person-tree>
          </group>
          <group>
            <Toast :value="toastValue" :is-show-mask="true" text="保存成功" @on-hide="saveSuccess"></Toast>
            <Toast
              :value="toastValueErr"
              :is-show-mask="true"
              :text="err"
              @on-hide="saveErr"
              type="cancel"
              width="200px"
            ></Toast>
          </group>
          <div style="text-align:center;display:flex" class="top-border" v-show="buttonFlag">
            <button
              :disabled="isDisable"
              class="userBack-button_save"
              @click="saveDailyCheckDraft"
            >暂存</button>
            <button
              :disabled="isDisable"
              class="userBack-button_submit"
              @click="saveDailyCheckInfo"
            >提交</button>
          </div>
          <div style="text-align:center;display:flex" class="top-border" v-show="!buttonFlag">
            <button class="userBack-button_submit" @click="saveDailyCheckInfo">提交</button>
          </div>
        </div>
      </v-touch>
    </div>
  </div>
</template>
 
<script>
import * as L from "leaflet";
//Vue.L = Vue.prototype.$L = L
import {
  Group,
  Cell,
  XButton,
  Box,
  GroupTitle,
  Flexbox,
  FlexboxItem,
  Divider,
  Calendar,
  PopupPicker,
  Toast,
  PopupRadio,
  InlineXSwitch,
  XSwitch,
  XInput
} from "vux";
import personTree from "@/components/tree/personTree";
var map = null;
var marker = null;
var flag = 0;
export default {
  components: {
    XButton,
    Box,
    GroupTitle,
    Group,
    Flexbox,
    FlexboxItem,
    Divider,
    Group,
    Cell,
    Calendar,
    PopupPicker,
    Toast,
    PopupRadio,
    InlineXSwitch,
    XSwitch,
    personTree,
    XInput
  },
  name: "HelloWorld",
  data() {
    return {
      option1: "A",
      options1: ["A", "B", "C"],
      msg: "Welcome to Your Vue.js App",
      pro: this.$route.query.pro,
      proId: this.$route.query.proId,
      centerPosition: this.$route.query.centerPosition,
      site: this.$route.query.centerPosition,
      //FatherClass:[fatherClass],
      name: this.$store.state.user.ADUSER_NAME,
      userId: this.$store.state.user.USER_NO,
      phone: this.$store.state.user.mobil,
      dept: this.$store.state.user.orgName,
      deptId: this.$store.state.user.orgId,
      DESCRIPTION: "",
      pageToken: "",
      fieldToken: "",
      buttonid: "",
      inputDate: this.$store.state.user.loginTime,
      // map:"",
      toastValue: false,
      toastValueErr: false,
      err: "",
      subject: "",
      startDate: "",
      endDate: "",
      notifyMethod: "0,0,0",
      notifyCheck: "",
      person:
        this.$route.query.reformer === undefined
          ? ""
          : this.$route.query.reformer,
      personId:
        this.$route.query.reformerId === undefined
          ? ""
          : this.$route.query.reformerId,
      checkerid: this.$store.state.user.userId,
      offlineUrl: [],
      buttonFlag: true,
      // checkDateFix: "",
      // checkItems: [],
      // checkItem: [],
      inspectMemberFullName: "",
      inspectMemberName: "",
      checkPerson: this.$store.state.user.ADUSER_NAME,
      checkPersonId: this.$store.state.user.USER_NO,
      SUPERVISORFULLNAME:
        this.$route.query.supervisorFullName === undefined
          ? ""
          : this.$route.query.supervisorFullName,
      SUPERVISORNAME:
        this.$route.query.supervisorName === undefined
          ? ""
          : this.$route.query.supervisorName,
      isDisable: false
    };
  },
  methods: {
    selectPro(val) {
      this.proId = val.id;
      this.pro = val.name;
      this.SUPERVISORFULLNAME =
        val.supervisorFullName === undefined ? "" : val.supervisorFullName;
      this.SUPERVISORNAME =
        val.supervisorName === undefined ? "" : val.supervisorName;
      this.person = val.reformer === undefined ? "" : val.reformer;
      this.personId = val.reformerId === undefined ? "" : val.reformerId;
    },
    selectSupervisorFullName(val) {
      this.SUPERVISORNAME = val;
      console.log("SUPERVISORNAME", this.SUPERVISORNAME);
    },
    selectPerson(val) {
      this.personId = val;
      console.log("personid", this.personId);
    },
    selectCheckPerson(val) {
      this.checkPersonId = val;
    },
    selectInspectMember(val) {
      this.inspectMemberName = val;
    },
    onSwipeRight() {
      this.$router.push({
        path: "/dailyCheck",
        query: { pro: this.pro, proId: this.proId, site: this.site }
      });
    },
    //     openSumlist(item) {
    //     //this.$store.commit('SET_CURRENT_ROW', item);
    //     this.$router.push({path:'/hidangereport',query:{pro:""}})
    // },
    loga(value) {
      console.log("value" + value);
      console.log("notifyMethod" + this.notifyMethod);
      console.log(this.person);
    },
    dateChange() {
      //var date = this.checkDate;
      this.startDate = this.startDate + " 00:00:00.000";
    },
    backhome() {
      if (this.checkNetWork()) {
        this.$router.push({
          path: "/dailyCheck",
          query: { pro: this.pro, proId: this.proId, site: this.site }
        });
      } else {
        this.$router.push("/offlineCklist");
      }
    },
    saveDailyCheckInfo() {
      this.isDisable = true;
      this.err = "";
      if (!this.pro) {
        this.err += "【项目（部）】不能为空<br/>";
      }
      // if (!this.subject) {
      //   this.err += "【任务名称】不能为空<br/>";
      // }
      if (this.startDate == "") {
        this.err += "【要求整改日期】不能为空<br/>";
        //console.log(this.FATHERCLASS.length)
      }
      if (!this.DESCRIPTION) {
        this.err += "【检查情况】不能为空<br/>";
      }
      if (this.person == "") {
        this.err += "【整改人】不能为空<br/>";
      }
      // if(this.inspectMemberName == ''){
      //   this.err += "【检查组员】不能为空<br/>";
      // }
      if (this.checkPerson == "") {
        this.err += "【检查人】不能为空<br/>";
      }
      if (this.SUPERVISORFULLNAME == "") {
        this.err += "【监理负责人】不能为空<br/>";
      }
      if (this.err != "") {
        this.toastValueErr = true;
        this.isDisable = false;
        return false;
      }
      if (this.checkNetWork()) {
        console.log("send");
        var guid = this.guid();
        var title = "日常巡检单提醒";
        var content =
          "你管理的" +
          this.pro +
          "项目有一个新的日常巡检单。请进入【日常巡检】查看详细信息。";
        var messageto = this.SUPERVISORNAME;
        var url =
          process.env.BASE_URL +
          "qhszpm/forms/SM/SAFECHECKINSPECT/SAFECHECKINSPECT_Add.html?isBreak=false&objName=SAFECHECKINSPECT&_useType=view&_pk=GUID&_t=474914&_winid=w5240&_pkValue=" +
          guid;

        var sendParams = {
          _method: "SYS_NOTICE.sendNotice",
          _param: {
            messageto: messageto,
            messagetilte: title,
            messagecontent: content,
            url: url,
            messagesenttime: new Date(),
            messageattachment: ""
          }
        };

        let sendJson = {
          FixJSON: JSON.stringify(sendParams)
        };
        this.$ajax({
          url: this.COMMON_URL,
          method: "post",
          // data: this.signMD5(sendJson)
          data: sendJson
        })
          .then(res => {})
          .catch(err => {
            console.log(err);
          });

        if (this.notifyMethod == "0,1,0") {
          this.notifyCheck = "SMS";
        }
        var params = {
          _method: "formService.saveFormData",
          requestEventData: {
            eventType: "formSubmitEvent",
            formType: 1,
            bizObjId: "SAFECHECKINSPECT",
            formId: "SAFECHECKINSPECT_Add",
            buttonId: "HandleCommand_1"
          },
          flowParam: {
            defKey: "SAFECHECKINSPECT",
            nodeId: "UserTask_1",
            userCommandType: "startandsubmit",
            userCommandId: "HandleCommand_1",
            isAdmin: "false",
            taskComment: "",
            extParam: {}
          },
          _OBJ_NAME_: "SAFECHECKINSPECT",
          _FORM_ID_: "SAFECHECKINSPECT_Add",
          useType: "add",
          pageToken: this.pageToken,
          formData: {
            objName: "SAFECHECKINSPECT",
            pks: ["GUID"],
            data: [
              {
                rowData: [
                  {
                    DataTarget: "GUID",
                    Value: guid,
                    OriginalValue: null,
                    PK: true,
                    DataType: "String"
                  },
                  {
                    DataTarget: "STATE",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "ATTACHMENTS",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "Store.ecidiDoc"
                  },
                  {
                    DataTarget: "ATTACHMENTS2",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "Store.ecidiDoc"
                  },
                  {
                    DataTarget: "PRJNAME",
                    Value: this.pro,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "PRJNO",
                    Value: null,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SYSPRJID",
                    Value: this.proId,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SUBJECT",
                    Value: this.subject,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "CHECKREQUIRED",
                    Value: this.DESCRIPTION,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "PLANDATE",
                    Value: this.startDate + " 00:00:00.000",
                    OriginalValue: null,
                    PK: false,
                    DataType: "TimeStamp"
                  },
                  {
                    DataTarget: "FINISHDATE",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "TimeStamp"
                  },
                  {
                    DataTarget: "ATTACHMENTS",
                    Value: this.fieldToken,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "ATTACHMENTS2",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "DESCRIPTION",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERFULLNAME",
                    Value: this.name,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERNAME",
                    Value: this.userId,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERDEPTNAME",
                    Value: this.dept,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERDEPTID",
                    Value: this.deptId,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "PHONENUM",
                    Value: this.phone,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTDATE",
                    Value: this.inputDate,
                    OriginalValue: null,
                    PK: false,
                    DataType: "TimeStamp"
                  },
                  {
                    DataTarget: "NOTIFYCHECK",
                    Value: this.notifyCheck,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "NOTIFYMETHOD",
                    Value: this.notifyMethod,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "REFORMER",
                    Value: this.person,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "REFORMERID",
                    Value: this.personId,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "FLAG",
                    Value: "不合格",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "CHECKER",
                    Value: this.checkPerson,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INSPECTMEMBERFULLNAME",
                    Value: this.inspectMemberFullName,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INSPECTMEMBERNAME",
                    Value: this.inspectMemberName,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SUPERVISORFULLNAME",
                    Value: this.SUPERVISORFULLNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SUPERVISORNAME",
                    Value: this.SUPERVISORNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "CHECKERID",
                    Value: this.checkPersonId,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  }
                ],
                children: []
              }
            ]
          },
          _ATTACHMENT_DELETE_IDS_: "",
          formInfo: {
            GUID: guid,
            STATE: "",
            ATTACHMENTS: this.fieldToken,
            ATTACHMENTS2: "",
            PRJNAME: this.pro,
            PRJNO: "",
            SYSPRJID: this.proId,
            SUBJECT: this.subject,
            CHECKREQUIRED: this.DESCRIPTION,
            PLANDATE: this.startDate,
            FINISHDATE: "",
            DESCRIPTION: "",
            INPUTERFULLNAME: this.name,
            INPUTERNAME: this.userId,
            INPUTERDEPTNAME: this.dept,
            INPUTERDEPTID: this.deptId,
            PHONENUM:this.phone,
            INPUTDATE: this.inputDate,
            NOTIFYCHECK: "",
            NOTIFYMETHOD: this.notifyMethod,
            REFORMER: this.person,
            REFORMERID: this.personId,
            FLAG: "不合格",
            CHECKER: this.checkPerson,
            INSPECTMEMBERFULLNAME: this.inspectMemberFullName,
            INSPECTMEMBERNAME: this.inspectMemberName,
            SUPERVISORFULLNAME: this.SUPERVISORFULLNAME,
            SUPERVISORNAME: this.SUPERVISORNAME,
            CHECKERID: this.checkPersonId
          }
        };
        let json = {
          FixJSON: JSON.stringify(params)
        };

        this.$ajax({
          url: this.COMMON_URL, //+ '?_objName=SAFECHECKINSPECT&_useType=add&_defKey=Flow_SAFECHECKINSPECT&_pk=GUID&_pkValue=undefined',
          method: "post",
          // data: this.signMD5(json)
          data: json
        })
          .then(res => {
            console.log("submit", res);
            this.toastValue = true;
            //console.log("");
          })
          .catch(err => {
            setTimeout(() => {
              this.isDisable = false;
            }, 1000);
            //console.log(err);
            alert(err);
            //this.err='';
          });
      } else {
        //执行离线状态时的任务
        let offline = this.$store.state.offlineflieurl;
        if (this.notifyMethod == "0,1,0") {
          this.notifyCheck = "SMS";
        }

        console.log("offline", offline);
        let urlOFFLINE = [];
        for (let i = 0; i < offline.length; i++) {
          let flies = offline[i].url.replace(/\./g, "||");
          // let fliess=flies.replace(/,/g,'_')
          urlOFFLINE.push(flies);
        }
        let offlineStr = urlOFFLINE.join(",");
        // urlOFFLINE = JSON.stringify(urlOFFLINE)
        console.log("urlOFFLINE", urlOFFLINE);
        this.$store.state.SQLiteDB.transaction(
          tx => {
            tx.executeSql(
              'INSERT INTO PMHSE_CHECKLIST (GUID,  STATE, ATTACHMENTS, ATTACHMENTS2, PRJNAME, PRJNO, SYSPRJID, SUBJECT ,CHECKREQUIRED,PLANDATE,FINISHDATE,DESCRIPTION,INPUTERFULLNAME,INPUTERNAME,INPUTERDEPTNAME,INPUTERDEPTID,PHONENUM,INPUTDATE,NOTIFYCHECK,NOTIFYMETHOD,REFORMER,REFORMERID,FLAG,CHECKER,INSPECTMEMBERFULLNAME,INSPECTMEMBERNAME,CHECKERID,FILEURL,SUPERVISORFULLNAME,SUPERVISORNAME) VALUES ("' +
                this.guid() +
                '", "' +
                "" +
                '", "' +
                this.fieldToken +
                '", "' +
                "" +
                '","' +
                this.pro +
                '","' +
                "" +
                '","' +
                this.proId +
                '","' +
                this.subject +
                '","' +
                this.DESCRIPTION +
                '","' +
                this.startDate +
                '","' +
                "" +
                '","' +
                "" +
                '","' +
                this.name +
                '","' +
                this.userId +
                '","' +
                this.dept +
                '","' +
                this.deptId +
                '","' +
                this.phone +
                '","' +
                this.inputDate +
                '","' +
                this.notifyCheck +
                '","' +
                this.notifyMethod +
                '","' +
                this.person +
                '","' +
                this.personId +
                '","' +
                "不合格" +
                '","' +
                this.checkPerson +
                '","' +
                this.inspectMemberFullName +
                '","' +
                this.inspectMemberName +
                '","' +
                this.checkPersonId +
                '","' +
                offlineStr +
                '","' +
                this.SUPERVISORFULLNAME +
                '","' +
                this.SUPERVISORNAME +
                '")'
            );
            // tx.executeSql('SELECT * FROM PMHSE_CHECKLIST', [],(tx,result)=>{
            // console.log('mylist',result)
            // let res =  result.rows[0].FILEURL
            // res = res.replace(/\|\|/g,".")
            // this.offlineUrl = res.split(",")
            // })
          },
          err => {
            console.log(err);
          }
        );
        this.toastValue = true;
      }
    },
    saveDailyCheckDraft() {
      this.isDisable = true;
      if (this.notifyMethod == "0,1,0") {
        this.notifyCheck = "SMS";
      }
      //this.dateChange();
      console.log("send");
      var params = {
        _method: "formService.saveFormData",
        requestEventData: {
          eventType: "formSubmitEvent",
          formType: 1,
          bizObjId: "SAFECHECKINSPECT",
          formId: "SAFECHECKINSPECT_Add",
          buttonId: "HandleCommand_3"
        },
        flowParam: {
          defKey: "SAFECHECKINSPECT",
          nodeId: "UserTask_1",
          userCommandType: "saveTaskDraft",
          userCommandId: "HandleCommand_3",
          isAdmin: "false",
          taskComment: "",
          extParam: {}
        },
        _OBJ_NAME_: "SAFECHECKINSPECT",
        _FORM_ID_: "SAFECHECKINSPECT_Add",
        useType: "add",
        pageToken: this.pageToken,
        formData: {
          objName: "SAFECHECKINSPECT",
          pks: ["GUID"],
          data: [
            {
              rowData: [
                {
                  DataTarget: "GUID",
                  Value: "",
                  OriginalValue: null,
                  PK: true,
                  DataType: "String"
                },
                {
                  DataTarget: "STATE",
                  Value: "",
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "ATTACHMENTS",
                  Value: "",
                  OriginalValue: null,
                  PK: false,
                  DataType: "Store.ecidiDoc"
                },
                {
                  DataTarget: "ATTACHMENTS2",
                  Value: "",
                  OriginalValue: null,
                  PK: false,
                  DataType: "Store.ecidiDoc"
                },
                {
                  DataTarget: "PRJNAME",
                  Value: this.pro,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "PRJNO",
                  Value: null,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "SYSPRJID",
                  Value: this.proId,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "SUBJECT",
                  Value: this.subject,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "CHECKREQUIRED",
                  Value: this.DESCRIPTION,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "PLANDATE",
                  Value: this.startDate,
                  OriginalValue: null,
                  PK: false,
                  DataType: "TimeStamp"
                },
                {
                  DataTarget: "FINISHDATE",
                  Value: "",
                  OriginalValue: null,
                  PK: false,
                  DataType: "TimeStamp"
                },
                {
                  DataTarget: "ATTACHMENTS",
                  Value: this.fieldToken,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "ATTACHMENTS2",
                  Value: "",
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "DESCRIPTION",
                  Value: "",
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "INPUTERFULLNAME",
                  Value: this.name,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "INPUTERNAME",
                  Value: this.userId,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "INPUTERDEPTNAME",
                  Value: this.dept,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "INPUTERDEPTID",
                  Value: this.deptId,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                    DataTarget: "PHONENUM",
                    Value: this.phone,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                {
                  DataTarget: "INPUTDATE",
                  Value: this.inputDate,
                  OriginalValue: null,
                  PK: false,
                  DataType: "TimeStamp"
                },
                {
                  DataTarget: "NOTIFYCHECK",
                  Value: this.notifyCheck,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "NOTIFYMETHOD",
                  Value: this.notifyMethod,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "REFORMER",
                  Value: this.person,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "REFORMERID",
                  Value: this.personId,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "FLAG",
                  Value: "不合格",
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "CHECKER",
                  Value: this.checkPerson,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "INSPECTMEMBERFULLNAME",
                  Value: this.inspectMemberFullName,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "INSPECTMEMBERNAME",
                  Value: this.inspectMemberName,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "SUPERVISORFULLNAME",
                  Value: this.SUPERVISORFULLNAME,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "SUPERVISORNAME",
                  Value: this.SUPERVISORNAME,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                },
                {
                  DataTarget: "CHECKERID",
                  Value: this.checkPersonId,
                  OriginalValue: null,
                  PK: false,
                  DataType: "String"
                }
              ],
              children: []
            }
          ]
        },
        _ATTACHMENT_DELETE_IDS_: "",
        formInfo: {
          GUID: "",
          STATE: "",
          ATTACHMENTS: this.fieldToken,
          ATTACHMENTS2: "",
          PRJNAME: this.pro,
          PRJNO: "",
          SYSPRJID: this.proId,
          SUBJECT: this.subject,
          CHECKREQUIRED: this.DESCRIPTION,
          PLANDATE: this.startDate,
          FINISHDATE: "",
          DESCRIPTION: "",
          INPUTERFULLNAME: this.name,
          INPUTERNAME: this.userId,
          INPUTERDEPTNAME: this.dept,
          INPUTERDEPTID: this.deptId,
          PHONENUM:this.phone,
          INPUTDATE: this.inputDate,
          NOTIFYCHECK: "",
          NOTIFYMETHOD: this.notifyMethod,
          REFORMER: this.person,
          REFORMERID: this.personId,
          FLAG: "不合格",
          CHECKER: this.checkPerson,
          INSPECTMEMBERFULLNAME: this.inspectMemberFullName,
          INSPECTMEMBERNAME: this.inspectMemberName,
          SUPERVISORFULLNAME: this.SUPERVISORFULLNAME,
          SUPERVISORNAME: this.SUPERVISORNAME,
          CHECKERID: this.checkPersonId
        }
      };
      let json = {
        FixJSON: JSON.stringify(params)
      };
      this.err = "";
      if (!this.pro) {
        this.err += "【项目（部）】不能为空<br/>";
      }
      if (this.err != "") {
        this.toastValueErr = true;
        this.isDisable = false;
        return false;
      }

      this.$ajax({
        url: this.COMMON_URL, //+ '?_objName=SAFECHECKINSPECT&_useType=add&_defKey=Flow_SAFECHECKINSPECT&_pk=GUID&_pkValue=undefined',
        method: "post",
        // data: this.signMD5(json)
        data: json
      })
        .then(res => {
          //console.log(res);
          this.toastValue = true;
          //console.log("");
        })
        .catch(err => {
          setTimeout(() => {
            this.isDisable = false;
          }, 1000);
          //console.log(err);
          alert(err);
          //this.err='';
        });
    },
    saveSuccess() {
      this.backhome();
    },
    saveErr() {
      this.toastValueErr = false;
    },
    setDefautlDate() {
      let now = new Date();
      let month = now.getMonth() + 1;
      let day = now.getDate();
      let hour = now.getHours();
      let min = now.getMinutes();
      let sec = now.getSeconds();
      if (month < 10) {
        month = "0" + month;
      }
      if (day < 10) {
        day = "0" + day;
      }
      if (hour < 10) {
        hour = "0" + hour;
      }
      if (min < 10) {
        min = "0" + min;
      }
      if (sec < 10) {
        sec = "0" + sec;
      }
      //this.checkDate = now.getFullYear() + "-" + month + "-" + day;
      // this.inputDate = now.getFullYear() + "-" + month + "-" + day;
      this.inputDate =
        now.getFullYear() +
        "-" +
        month +
        "-" +
        day +
        " " +
        hour +
        ":" +
        min +
        ":" +
        sec;
      // this.dateChange()
    }
  },
  mounted() {
    if (this.checkNetWork()) {
      this.buttonFlag = true;
    } else {
      //执行离线状态时的任务
      this.buttonFlag = false;
    }
    console.log(this.$store.state.user);
    // if (new Date().getDate() > 10)
    //   this.inputDate = this.inputDate.substr(0, 10);
    // else
    //   this.inputDate = this.inputDate.substr(0, 9);
    // var greenIcon = L.icon({
    //   iconUrl: '../src/assets/img/sign-in.png',
    //   iconSize: [26, 44], // size of the icon
    //   iconAnchor: [17, 48], // point of the icon which will correspond to marker's location
    //   //popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor
    // });
    this.setDefautlDate();
    this.pageToken = this.guid(); //this.sPageToken();
    // this.fieldToken = this.guid();
    this.buttonid = this.guid();
    // console.log("jahsdkjasdkjh" + this.centerPosition);
    // map = L.map('map', {
    //   center: [22.521671, 113.895794],
    //   zoom: 13
    // });
    // L.tileLayer(
    //   "http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",
    //   //  "http://t0.tianditu.gov.cn/vec_c/wmts?tk=2528436969e251e7e601cb6989d0b8ee",
    //   {
    //     subdomains: ["1", "2", "3", "4"],
    //     attribution: "高德"
    //   }
    // ).addTo(map);
    // map.on('click', onMapClick);
    // let th = this;
    // function onMapClick (e) {
    //   if (marker) {
    //     map.removeLayer(marker)
    //   }
    //   marker = new L.Marker(e.latlng, { icon: greenIcon }).addTo(map);
    //   map.addLayer(marker);
    //   th.site = "LatLng(" + e.latlng.lat.toString().substr(0, 8) + "," + e.latlng.lng.toString().substr(0, 9) + ")";
    // }
    // this.selectFather();
    //console.log(this.centerPosition);
    //var locate = this.centerPosition;
    // var long=this.centerPosition;
    // var long = locate.slice(locate.indexOf("(") + 1, locate.indexOf(","));
    // var latitude = locate.slice(locate.indexOf(",") + 2, locate.indexOf(")"));
    //console.log(long);
    //console.log(latitude);
    //L.marker([long, latitude]).addTo(map).bindPopup("watch函数").openPopup();
    // if (marker) {
    //   map.removeLayer(marker)
    // }
    // marker = new L.Marker([long, latitude], { icon: greenIcon }).addTo(map);
    // map.addLayer(marker);
    // map.panTo([long, latitude]);
  },
  watch: {
    // centerPosition: {
    //   handler (newval) {
    //     var locate = this.centerPosition;
    //     var long = locate.slice(locate.indexOf("(") + 1, locate.indexOf(","));
    //     var latitude = locate.slice(locate.indexOf(",") + 2, locate.indexOf(")"));
    //     if (marker) {
    //       map.removeLayer(marker)
    //     }
    //     marker = new L.Marker([long, latitude], { icon: greenIcon }).addTo(map);
    //     map.addLayer(marker);
    //   },
    // }
  }
};
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* .transition-view /deep/.weui-cells__title {
      margin-top: 0.77em;
    margin-bottom: 0.3em;
    padding-left: 15px;
    padding-right: 15px;
    color: #353535;
    font-size: 14px;
} */
/* .transition-view /deep/ .vux-header .vux-header-left .left-arrow:before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.8);
  border-width: 1px 0 0 1px;
  -webkit-transform: rotate(315deg);
  transform: rotate(315deg);
  top: 8px;
  left: 7px;
}
.transition-view /deep/ .vux-header .vux-header-title {
  line-height: 40px;
  text-align: center;
  font-size: 18px;
  font-weight: 400;
  color: #333;
} */
.transition-view /deep/ .weui-cells:after {
  border-bottom: none;
}

#map {
  width: 100%;
  height: 25%;
}
.content {
  width: 100%;
  height: 75%;
}
.userBack-button_save {
  width: 40%;
  height: 40px;
  background-color: #ffffff;
  border-radius: 2pt;
  border: 1pt solid #4d86ff;
  margin-top: 20pt;
  color: #4d86ff;
  font-size: 13px;
  /* margin-left: 15px; */
  margin-right: auto;
  margin-left: auto;
  margin-bottom: 20pt;
}
.userBack-button_submit {
  width: 40%;
  height: 40px;
  background-color: #4d86ff;
  border-radius: 2pt;
  border: 1pt solid #4d86ff;
  margin-top: 20pt;
  color: #ffffff;
  font-size: 13px;
  /* margin-left: auto;
      margin-right: 5%; */
  margin-right: auto;
  margin-left: auto;
  margin-bottom: 20pt;
}
.top-border {
  border-top: 1px solid #f5f5f5;
}
</style>